-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1d4f01
commit 2ccd393
Showing
17 changed files
with
2,382 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
....iotbroker.embeddediotagent.registry/META-INF/spring/embeddediotagentregistry-context.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" | ||
xmlns:context="http://www.springframework.org/schema/context" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> | ||
|
||
<context:component-scan | ||
base-package="eu.neclab.iotplatform.iotbroker.embeddediotagent.registry" /> | ||
|
||
<bean id="registry" | ||
class="eu.neclab.iotplatform.iotbroker.embeddediotagent.registry.Registry"> | ||
<property name="indexer" ref="EmbeddedAgentIndexer"></property> | ||
<property name="ngsi9Client" ref="Ngsi9Interface"></property> | ||
<property name="permanentRegistry" ref="PermanentRegistry"></property> | ||
</bean> | ||
|
||
|
||
<context:property-placeholder | ||
location="file:///${dir.config}/iotbrokerconfig/embeddedAgent/couchdb.xml" | ||
order="1" ignore-unresolvable="true" /> | ||
|
||
<context:property-placeholder | ||
location="file:///${dir.config}/iotbrokerconfig/iotBroker/config/config.xml" | ||
order="2" ignore-unresolvable="true" /> | ||
|
||
|
||
</beans> |
22 changes: 22 additions & 0 deletions
22
...orm.iotbroker.embeddediotagent.registry/META-INF/spring/embeddediotagentregistry-osgi.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans.xsd | ||
http://www.springframework.org/schema/osgi | ||
http://www.springframework.org/schema/osgi/spring-osgi.xsd"> | ||
|
||
<osgi:service id="Registry" ref="registry" | ||
interface="eu.neclab.iotplatform.iotbroker.commons.interfaces.EmbeddedAgentRegistryInterface" /> | ||
|
||
<osgi:reference id="EmbeddedAgentIndexer" | ||
interface="eu.neclab.iotplatform.iotbroker.commons.interfaces.EmbeddedAgentIndexerInterface"></osgi:reference> | ||
|
||
<osgi:reference id="PermanentRegistry" | ||
interface="eu.neclab.iotplatform.iotbroker.commons.interfaces.PermanentRegistryInterface"></osgi:reference> | ||
|
||
|
||
<osgi:reference id="Ngsi9Interface" | ||
interface="eu.neclab.iotplatform.ngsi.api.ngsi9.Ngsi9Interface" | ||
bean-name="connector"></osgi:reference> | ||
</beans> |
142 changes: 142 additions & 0 deletions
142
eu.neclab.iotplatform.iotbroker.embeddediotagent.registry/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>IoTbrokerParent</artifactId> | ||
<groupId>eu.neclab.iotplatform</groupId> | ||
<version>6.1-SNAPSHOT</version> | ||
<relativePath>../IoTbrokerParent</relativePath> | ||
</parent> | ||
|
||
<artifactId>iotbroker.embeddediotagent.registry</artifactId> | ||
<packaging>bundle</packaging> | ||
|
||
|
||
<repositories> | ||
<repository> | ||
<id>EclipseLink Repo</id> | ||
<url>http://download.eclipse.org/rt/eclipselink/maven.repo</url> | ||
</repository> | ||
</repositories> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
</resource> | ||
<resource> | ||
<directory>.</directory> | ||
<includes> | ||
<include>META-INF/**</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<manifestLocation>META-INF</manifestLocation> | ||
<instructions> | ||
<Private-Package>eu.neclab.iotplatform.couchdb.*</Private-Package> | ||
<!-- <Import-Package>com.google.gson;version="2.2.2", --> | ||
<!-- eu.neclab.iotplatform.iotbroker.client;version="${project.version}", --> | ||
<!-- eu.neclab.iotplatform.iotbroker.commons;version="${project.version}", --> | ||
<!-- eu.neclab.iotplatform.iotbroker.commons.interfaces;version="${project.version}", --> | ||
<!-- eu.neclab.iotplatform.ngsi.api.datamodel;version="${project.version}", --> | ||
<!-- eu.neclab.iotplatform.ngsi.api.ngsi10;version="${project.version}", --> | ||
<!-- eu.neclab.iotplatform.iotbroker.storage;version="${project.version}, --> | ||
<!-- org.apache.commons.codec.binary;version="1.6.0", --> | ||
<!-- org.apache.log4j;version="1.2.15", --> | ||
<!-- org.json;version="1.0.0", --> | ||
<!-- org.apache.http, --> | ||
<!-- org.apache.http.auth, --> | ||
<!-- org.apache.http.impl.auth, --> | ||
<!-- org.springframework.beans;version="${spring.version}", --> | ||
<!-- org.springframework.beans.annotation;version="${spring.version}", --> | ||
<!-- org.springframework.beans.factory;version="${spring.version}", --> | ||
<!-- org.springframework.beans.factory.annotation;version="${spring.version}", --> | ||
<!-- org.springframework.stereotype;version="${spring.version}", --> | ||
<!-- org.springframework.web;version="${spring.version}", --> | ||
<!-- org.springframework.web.bind;version="${spring.version}", --> | ||
<!-- org.springframework.web.bind.annotation;version="${spring.version}", --> | ||
<!-- org.springframework.web.context;version="${spring.version}", --> | ||
<!-- org.springframework.web.servlet.mvc;version="${spring.version}", --> | ||
<!-- org.springframework.web.servlet.mvc.annotation;version="${spring.version}", --> | ||
<!-- javax.xml.bind;version="2.0.0", --> | ||
<!-- org.codehaus.jackson;version="[1.4,2)", --> | ||
<!-- org.codehaus.jackson.map;version="[1.4,2)", --> | ||
<!-- org.codehaus.jackson.map.annotate;version="[1.4,2)", --> | ||
<!-- com.google.common.collect;version="17.0.0" --> | ||
<!-- </Import-Package> --> | ||
</instructions> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>4.3.4</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpcore</artifactId> | ||
<version>4.3.2</version> | ||
</dependency> | ||
|
||
<!-- GUAVA --> | ||
<dependency> | ||
<groupId>org.json</groupId> | ||
<artifactId>json</artifactId> | ||
<version>20140107</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>2.2.2</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>eu.neclab.iotplatform</groupId> | ||
<artifactId>iotbroker.commons</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>eu.neclab.iotplatform</groupId> | ||
<artifactId>ngsi.api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>eu.neclab.iotplatform</groupId> | ||
<artifactId>iotbroker.client</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>eu.neclab.iotplatform</groupId> | ||
<artifactId>iotbroker.storage</artifactId> | ||
</dependency> | ||
|
||
<!-- <dependency> --> | ||
<!-- <groupId>joda-time</groupId> --> | ||
<!-- <artifactId>joda-time</artifactId> --> | ||
<!-- <version>2.8.1</version> --> | ||
<!-- </dependency> --> | ||
|
||
|
||
<dependency> | ||
<groupId>javax.xml.bind</groupId> | ||
<artifactId>jaxb-api</artifactId> | ||
<version>2.2.11</version> | ||
</dependency> | ||
|
||
|
||
</dependencies> | ||
|
||
</project> |
53 changes: 53 additions & 0 deletions
53
...eclab/iotplatform/iotbroker/embeddediotagent/registry/EmbeddedAgentIdentifierFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package eu.neclab.iotplatform.iotbroker.embeddediotagent.registry; | ||
|
||
import eu.neclab.iotplatform.ngsi.api.datamodel.ContextMetadata; | ||
import eu.neclab.iotplatform.ngsi.api.datamodel.MetadataTypes; | ||
|
||
public class EmbeddedAgentIdentifierFactory { | ||
|
||
public static ContextMetadata getEmbeddedAgentIdentifier(String identifier) { | ||
return new ContextMetadata( | ||
MetadataTypes.EmbeddedAgentIdentifier.getName(), null, | ||
identifier); | ||
} | ||
|
||
public static boolean compare(ContextMetadata embeddedAgentIdentifier, | ||
ContextMetadata contextMetadata) { | ||
|
||
if (embeddedAgentIdentifier == null) { | ||
if (contextMetadata == null) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
if (contextMetadata == null) { | ||
return false; | ||
} | ||
|
||
// System.out.println(MetadataTypes.EmbeddedAgentIdentifier.getName()); | ||
|
||
if (contextMetadata.getName().toLowerCase().equals( | ||
MetadataTypes.EmbeddedAgentIdentifier.getName().toLowerCase())) { | ||
|
||
if (contextMetadata.getValue() instanceof String) { | ||
|
||
if (((String) embeddedAgentIdentifier.getValue()) | ||
.equals((String) contextMetadata.getValue())) { | ||
return true; | ||
|
||
} else { | ||
return false; | ||
} | ||
|
||
} else { | ||
return false; | ||
} | ||
|
||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
} |
73 changes: 73 additions & 0 deletions
73
...eclab/iotplatform/iotbroker/embeddediotagent/registry/LockableRegisterContextRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package eu.neclab.iotplatform.iotbroker.embeddediotagent.registry; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.locks.ReentrantLock; | ||
|
||
import eu.neclab.iotplatform.ngsi.api.datamodel.ContextMetadata; | ||
import eu.neclab.iotplatform.ngsi.api.datamodel.ContextRegistration; | ||
import eu.neclab.iotplatform.ngsi.api.datamodel.ContextRegistrationAttribute; | ||
import eu.neclab.iotplatform.ngsi.api.datamodel.EntityId; | ||
import eu.neclab.iotplatform.ngsi.api.datamodel.RegisterContextRequest; | ||
|
||
public class LockableRegisterContextRequest { | ||
private ReentrantLock lock = new ReentrantLock(); | ||
|
||
private RegisterContextRequest registerContextRequest = new RegisterContextRequest(); | ||
|
||
public RegisterContextRequest getRegisterContextRequest() { | ||
return registerContextRequest; | ||
} | ||
|
||
public void setRegisterContextRequest( | ||
RegisterContextRequest registerContextRequest) { | ||
this.registerContextRequest = registerContextRequest; | ||
} | ||
|
||
LockableRegisterContextRequest(ContextMetadata embeddedAgentIdentifier) { | ||
super(); | ||
List<ContextRegistration> contextRegistrationList = new ArrayList<ContextRegistration>(); | ||
ContextRegistration contextRegistration = new ContextRegistration(); | ||
contextRegistrationList.add(contextRegistration); | ||
|
||
List<ContextMetadata> contextMetadataList = new ArrayList<ContextMetadata>(); | ||
contextRegistration.setListContextMetadata(contextMetadataList); | ||
|
||
if (embeddedAgentIdentifier != null) { | ||
contextMetadataList.add(embeddedAgentIdentifier); | ||
} | ||
|
||
List<EntityId> entityIdList = new ArrayList<EntityId>(); | ||
contextRegistration.setListEntityId(entityIdList); | ||
|
||
List<ContextRegistrationAttribute> contextRegistrationAttributeList = new ArrayList<ContextRegistrationAttribute>(); | ||
contextRegistration | ||
.setListContextRegistrationAttribute(contextRegistrationAttributeList); | ||
|
||
registerContextRequest | ||
.setContextRegistrationList(contextRegistrationList); | ||
} | ||
|
||
public ContextRegistration getContextRegistration() { | ||
return registerContextRequest.getContextRegistrationList().iterator() | ||
.next(); | ||
} | ||
|
||
public void setContextRegistration(ContextRegistration contextRegistration) { | ||
List<ContextRegistration> contextRegistrationList = new ArrayList<ContextRegistration>(); | ||
contextRegistrationList.add(contextRegistration); | ||
registerContextRequest | ||
.setContextRegistrationList(contextRegistrationList); | ||
} | ||
|
||
public void lock() { | ||
lock.lock(); | ||
} | ||
|
||
public void unlock() { | ||
lock.unlock(); | ||
} | ||
|
||
} |
Oops, something went wrong.