Author: chris.laprun(a)jboss.com
Date: 2011-09-16 10:50:21 -0400 (Fri, 16 Sep 2011)
New Revision: 7455
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/JCRConsumerRegistry.java
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/EndpointInfoMapping.java
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfoMapping.java
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfosMapping.java
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/jcr/mapping/mixins/WSSEndpointEnabled.java
Log:
- GTNWSRP-239: simplifying handling of mixins
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/JCRConsumerRegistry.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/JCRConsumerRegistry.java 2011-09-16
12:28:21 UTC (rev 7454)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/JCRConsumerRegistry.java 2011-09-16
14:50:21 UTC (rev 7455)
@@ -35,7 +35,6 @@
import org.gatein.wsrp.consumer.registry.xml.XMLConsumerRegistry;
import org.gatein.wsrp.jcr.ChromatticPersister;
import org.gatein.wsrp.jcr.StoresByPathManager;
-import org.gatein.wsrp.jcr.mapping.mixins.BaseMixin;
import org.gatein.wsrp.jcr.mapping.mixins.LastModified;
import org.gatein.wsrp.jcr.mapping.mixins.ModifyRegistrationRequired;
import org.gatein.wsrp.jcr.mapping.mixins.WSSEndpointEnabled;
@@ -76,7 +75,7 @@
{
Collections.addAll(mappingClasses, ProducerInfosMapping.class,
ProducerInfoMapping.class,
EndpointInfoMapping.class, RegistrationInfoMapping.class,
RegistrationPropertyMapping.class,
- RegistrationPropertyDescriptionMapping.class, LastModified.class,
ModifyRegistrationRequired.class,
+ RegistrationPropertyDescriptionMapping.class, LastModified.class,
ModifyRegistrationRequired.class,
WSSEndpointEnabled.class);
}
@@ -123,25 +122,19 @@
{
ChromatticSession session = persister.getSession();
+ // update cache
+ final long now = System.currentTimeMillis();
+ lastModified = now;
+
ProducerInfosMapping pims = getProducerInfosMapping(session);
+ pims.setLastModified(now);
+
ProducerInfoMapping pim = pims.createProducerInfo(info.getId());
String key = session.persist(pims, pim, info.getId());
info.setKey(key);
+ info.setLastModified(now);
pim.initFrom(info);
- // update cache
- final long now = System.currentTimeMillis();
- lastModified = now;
-// getRefreshedInfoCache(session).put(info.getId(), info);
-
- // GTNWSRP-239
- getMixin(pims, session, LastModified.class).setLastModified(now);
- getMixin(pim, session, LastModified.class).setLastModified(now);
- getMixin(pim, session,
ModifyRegistrationRequired.class).setModifyRegistrationRequired(info.isModifyRegistrationRequired());
- info.setLastModified(now);
- getMixin(pim.getEndpointInfo(), session,
WSSEndpointEnabled.class).setWSSEnabled(info.getEndpointConfigurationInfo().getWSSEnabled());
-
-
persister.closeSession(true);
}
catch (Exception e)
@@ -176,6 +169,8 @@
synchronized (this)
{
+ final long now = System.currentTimeMillis();
+
ProducerInfoMapping pim = session.findById(ProducerInfoMapping.class, key);
if (pim == null)
{
@@ -183,32 +178,21 @@
}
oldId = pim.getId();
newId = producerInfo.getId();
+ producerInfo.setLastModified(now);
pim.initFrom(producerInfo);
idUnchanged = oldId.equals(newId);
- final long now = System.currentTimeMillis();
if (!idUnchanged)
{
ProducerInfosMapping pims = getProducerInfosMapping(session);
Map<String, ProducerInfoMapping> nameToProducerInfoMap =
pims.getNameToProducerInfoMap();
nameToProducerInfoMap.put(pim.getId(), pim);
- // update cache
- /*getRefreshedInfoCache(session).remove(oldId);
- getRefreshedInfoCache(session).put(newId, producerInfo);*/
-
- // GTNWSRP-239
- getMixin(pims, session, LastModified.class).setLastModified(now);
+ pims.setLastModified(now);
lastModified = now;
}
- // GTNWSRP-239
- getMixin(pim, session,
ModifyRegistrationRequired.class).setModifyRegistrationRequired(producerInfo.isModifyRegistrationRequired());
- getMixin(pim, session, LastModified.class).setLastModified(now);
- producerInfo.setLastModified(now);
- getMixin(pim.getEndpointInfo(), session,
WSSEndpointEnabled.class).setWSSEnabled(producerInfo.getEndpointConfigurationInfo().getWSSEnabled());
-
persister.closeSession(true);
}
@@ -219,13 +203,13 @@
public Iterator<ProducerInfo> getProducerInfosFromStorage()
{
ChromatticSession session = persister.getSession();
-
+
Collection<WSRPConsumer> consumers =
getRefreshedInfoCache(session).getConsumers();
-
+
// GTNWSRP-239
// Kindof crappy place to put this, but we need to be able to retrieve the mixin
from the jcr so that it can be used to
// configure the ProducerInfo
- Iterator<WSRPConsumer> consumersIterator = consumers.iterator();
+ /*Iterator<WSRPConsumer> consumersIterator = consumers.iterator();
while (consumersIterator.hasNext())
{
ProducerInfo pi = consumersIterator.next().getProducerInfo();
@@ -240,8 +224,8 @@
{
pi.getEndpointConfigurationInfo().setWSSEnabled(wssee.getWSSEnabled());
}
- }
-
+ }*/
+
final Iterator<ProducerInfo> iterator = new
ProducerInfoIterator(consumers.iterator());
persister.closeSession(false);
return iterator;
@@ -273,13 +257,13 @@
ProducerInfosMapping producerInfosMapping = getProducerInfosMapping(session);
// check if we need to refresh the local cache
- if (lastModified < getMixin(producerInfosMapping, session,
LastModified.class).getLastModified())
+ if (lastModified < producerInfosMapping.getLastModified())
{
List<ProducerInfoMapping> mappings =
producerInfosMapping.getProducerInfos();
for (ProducerInfoMapping pim : mappings)
{
- if (lastModified < getMixin(pim, session,
LastModified.class).getLastModified())
+ if (lastModified < pim.getLastModified())
{
consumers.putConsumer(pim.getId(), createConsumerFrom(pim.toModel(null,
this)));
}
@@ -334,7 +318,7 @@
}
}
- private <M extends BaseMixin> M getMixin(Object objectToCheck, ChromatticSession
session, Class<M> type)
+ /*private <M extends BaseMixin> M getMixin(Object objectToCheck,
ChromatticSession session, Class<M> type)
{
M mixin = session.getEmbedded(objectToCheck, type);
if (mixin == null)
@@ -344,7 +328,7 @@
mixin.initializeValue();
}
return mixin;
- }
+ }*/
@Override
public boolean containsConsumer(String id)
@@ -467,7 +451,7 @@
}
lastModified = System.currentTimeMillis();
- getMixin(producerInfosMapping, session,
LastModified.class).setLastModified(lastModified);
+ producerInfosMapping.setLastModified(lastModified);
session.save();
}
}
@@ -486,7 +470,7 @@
if (pims != null)
{
// GTNWSRP-239
- return getMixin(pims, session, LastModified.class);
+ return pims.getLastModifiedMixin();
}
else
{
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/EndpointInfoMapping.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/EndpointInfoMapping.java 2011-09-16
12:28:21 UTC (rev 7454)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/EndpointInfoMapping.java 2011-09-16
14:50:21 UTC (rev 7455)
@@ -23,10 +23,14 @@
package org.gatein.wsrp.consumer.registry.mapping;
-import org.chromattic.api.annotations.DefaultValue;
+import org.chromattic.api.RelationshipType;
+import org.chromattic.api.annotations.Create;
+import org.chromattic.api.annotations.OneToOne;
+import org.chromattic.api.annotations.Owner;
import org.chromattic.api.annotations.PrimaryType;
import org.chromattic.api.annotations.Property;
import org.gatein.wsrp.consumer.EndpointConfigurationInfo;
+import org.gatein.wsrp.jcr.mapping.mixins.WSSEndpointEnabled;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -47,16 +51,49 @@
public abstract void setWSTimeoutMilliseconds(Integer expiration);
+ @OneToOne(type = RelationshipType.EMBEDDED)
+ @Owner
+ public abstract WSSEndpointEnabled getWSSEndpointEnabledMixin();
+
+ protected abstract void setWSSEndpointEnabledMixin(WSSEndpointEnabled mixin);
+
+ @Create
+ protected abstract WSSEndpointEnabled createWSSEndpointEnabledMixin();
+
+ public void setWSSEnabled(boolean wssEnabled)
+ {
+ getCreatedWSSEndpointEnabledMixin().setWSSEnabled(wssEnabled);
+ }
+
+ public boolean isWSSEnabled()
+ {
+ return getCreatedWSSEndpointEnabledMixin().getWSSEnabled();
+ }
+
public void initFrom(EndpointConfigurationInfo info)
{
setWSDLURL(info.getWsdlDefinitionURL());
setWSTimeoutMilliseconds(info.getWSOperationTimeOut());
+ setWSSEnabled(info.getWSSEnabled());
}
EndpointConfigurationInfo toEndpointConfigurationInfo(EndpointConfigurationInfo
initial)
{
initial.setWsdlDefinitionURL(getWSDLURL());
initial.setWSOperationTimeOut(getWSTimeoutMilliseconds());
+ initial.setWSSEnabled(isWSSEnabled());
return initial;
}
+
+ private WSSEndpointEnabled getCreatedWSSEndpointEnabledMixin()
+ {
+ WSSEndpointEnabled wssEndpointEnabledMixin = getWSSEndpointEnabledMixin();
+ if (wssEndpointEnabledMixin == null)
+ {
+ wssEndpointEnabledMixin = createWSSEndpointEnabledMixin();
+ setWSSEndpointEnabledMixin(wssEndpointEnabledMixin);
+ wssEndpointEnabledMixin.initializeValue();
+ }
+ return wssEndpointEnabledMixin;
+ }
}
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfoMapping.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfoMapping.java 2011-09-16
12:28:21 UTC (rev 7454)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfoMapping.java 2011-09-16
14:50:21 UTC (rev 7455)
@@ -23,6 +23,8 @@
package org.gatein.wsrp.consumer.registry.mapping;
+import org.chromattic.api.RelationshipType;
+import org.chromattic.api.annotations.Create;
import org.chromattic.api.annotations.DefaultValue;
import org.chromattic.api.annotations.Id;
import org.chromattic.api.annotations.MappedBy;
@@ -35,6 +37,8 @@
import org.gatein.wsrp.consumer.RegistrationInfo;
import org.gatein.wsrp.consumer.spi.ConsumerRegistrySPI;
import org.gatein.wsrp.jcr.mapping.BaseMapping;
+import org.gatein.wsrp.jcr.mapping.mixins.LastModified;
+import org.gatein.wsrp.jcr.mapping.mixins.ModifyRegistrationRequired;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -74,16 +78,56 @@
@Id
public abstract String getKey();
+ @OneToOne(type = RelationshipType.EMBEDDED)
+ @Owner
+ public abstract LastModified getLastModifiedMixin();
+
+ protected abstract void setLastModifiedMixin(LastModified lastModifiedMixin);
+
+ @Create
+ protected abstract LastModified createLastModifiedMixin();
+
+ @OneToOne(type = RelationshipType.EMBEDDED)
+ @Owner
+ public abstract ModifyRegistrationRequired getModifyRegistrationRequiredMixin();
+
+ protected abstract void setModifyRegistrationRequiredMixin(ModifyRegistrationRequired
mmr);
+
+ @Create
+ protected abstract ModifyRegistrationRequired
createModifyRegistrationRequiredMixin();
+
/* @Property(name = "available")
public abstract boolean getAvailable();
public abstract void setAvailable(boolean available);*/
+ public void setModifyRegistrationRequired(boolean modifyRegistrationRequired)
+ {
+
getCreatedModifyRegistrationRequiredMixin().setModifyRegistrationRequired(modifyRegistrationRequired);
+ }
+
+ public boolean getModifyRegistrationRequired()
+ {
+ return getCreatedModifyRegistrationRequiredMixin().isModifyRegistrationRequired();
+ }
+
+ public void setLastModified(long lastModified)
+ {
+ getCreatedLastModifiedMixin().setLastModified(lastModified);
+ }
+
+ public long getLastModified()
+ {
+ return getCreatedLastModifiedMixin().getLastModified();
+ }
+
public void initFrom(ProducerInfo producerInfo)
{
setActive(producerInfo.isActive());
setExpirationCacheSeconds(producerInfo.getExpirationCacheSeconds());
setId(producerInfo.getId());
+ setLastModified(producerInfo.getLastModified());
+ setModifyRegistrationRequired(producerInfo.isModifyRegistrationRequired());
EndpointInfoMapping eim = getEndpointInfo();
eim.initFrom(producerInfo.getEndpointConfigurationInfo());
@@ -107,6 +151,8 @@
info.setId(getId());
info.setActive(getActive());
info.setExpirationCacheSeconds(getExpirationCacheSeconds());
+ info.setLastModified(getLastModified());
+ info.setModifyRegistrationRequired(getModifyRegistrationRequired());
// endpoint
EndpointConfigurationInfo endInfo =
getEndpointInfo().toEndpointConfigurationInfo(info.getEndpointConfigurationInfo());
@@ -118,4 +164,28 @@
return info;
}
+
+ private LastModified getCreatedLastModifiedMixin()
+ {
+ LastModified lm = getLastModifiedMixin();
+ if (lm == null)
+ {
+ lm = createLastModifiedMixin();
+ setLastModifiedMixin(lm);
+ lm.initializeValue();
+ }
+ return lm;
+ }
+
+ private ModifyRegistrationRequired getCreatedModifyRegistrationRequiredMixin()
+ {
+ ModifyRegistrationRequired mmr = getModifyRegistrationRequiredMixin();
+ if (mmr == null)
+ {
+ mmr = createModifyRegistrationRequiredMixin();
+ setModifyRegistrationRequiredMixin(mmr);
+ mmr.initializeValue();
+ }
+ return mmr;
+ }
}
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfosMapping.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfosMapping.java 2011-09-16
12:28:21 UTC (rev 7454)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/consumer/registry/mapping/ProducerInfosMapping.java 2011-09-16
14:50:21 UTC (rev 7455)
@@ -23,9 +23,13 @@
package org.gatein.wsrp.consumer.registry.mapping;
+import org.chromattic.api.RelationshipType;
import org.chromattic.api.annotations.Create;
import org.chromattic.api.annotations.OneToMany;
+import org.chromattic.api.annotations.OneToOne;
+import org.chromattic.api.annotations.Owner;
import org.chromattic.api.annotations.PrimaryType;
+import org.gatein.wsrp.jcr.mapping.mixins.LastModified;
import java.util.List;
import java.util.Map;
@@ -47,4 +51,37 @@
@Create
public abstract ProducerInfoMapping createProducerInfo(String producerId);
+
+ @OneToOne(type = RelationshipType.EMBEDDED)
+ @Owner
+ public abstract LastModified getLastModifiedMixin();
+
+ protected abstract void setLastModifiedMixin(LastModified lastModifiedMixin);
+
+ @Create
+ protected abstract LastModified createLastModifiedMixin();
+
+ public void setLastModified(long lastModified)
+ {
+ getCreatedLastModifiedMixin().setLastModified(lastModified);
+ }
+
+ public long getLastModified()
+ {
+ return getCreatedLastModifiedMixin().getLastModified();
+ }
+
+ private LastModified getCreatedLastModifiedMixin()
+ {
+ LastModified lm = getLastModifiedMixin();
+ if (lm == null)
+ {
+ lm = createLastModifiedMixin();
+ setLastModifiedMixin(lm);
+ lm.initializeValue();
+ }
+ return lm;
+ }
+
+
}
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/jcr/mapping/mixins/WSSEndpointEnabled.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/jcr/mapping/mixins/WSSEndpointEnabled.java 2011-09-16
12:28:21 UTC (rev 7454)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/jcr/mapping/mixins/WSSEndpointEnabled.java 2011-09-16
14:50:21 UTC (rev 7455)
@@ -34,12 +34,11 @@
public abstract class WSSEndpointEnabled implements BaseMixin
{
@Property(name = "enablewss")
- @DefaultValue("false")
+ @DefaultValue("false")
public abstract boolean getWSSEnabled();
-
+
public abstract void setWSSEnabled(boolean enable);
-
- @Override
+
public void initializeValue()
{
//set to false by default